<?php
/* admenu1.php 2006-07-02 12:48:44
   Conference Registration - Registration for conferences - A XOOPS CMS Module
   Copyright (c) 2006 Kevin van Haaren, US
   URL:     http://www.superfantasmoworld.com/
   Contact: kevin@vanhaaren.net
 	
   XOOPS
   Copyright (c) 2000 XOOPS.org
   URL:     http://www.xoops.org/
    
   This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    
 */
 
//The next comment block is for PHPDocumentor
/**
 * Conference Registration - Registration for conferences
 * 
 * Admin menu option:
 * Get Stats for a conference
 * 
 * @author Kevin van Haaren (kevin@vanhaaren.net)
 * @copyright 2006 Kevin van Haaren, US
 * @package CONFREG
 * @subpackage Admin_Function
 * 
 */

/**
* Do all the declarations etc needed by an admin page
*/
include_once "adminheader.inc";

//Display the admin menu
xoops_module_admin_menu(2,_AM_CONFREG_ADMENU1);

/**
* To use this as a template you need to write code to display
* whatever it is you want displaying between here...
*/

/* echo "Please edit admenu1.php to display your information for this page"; */

	echo '<h3>Summary of Registration Information</h3>';
	echo '<h3>Daily Attendence</h3>';

	$confHdl = $xoopsDB->query(	'SELECT days_attending AS days, COUNT(*) AS reg_count' .
								' FROM ' . $xoopsDB->prefix('confreg_people') .
								' WHERE confid=1' .
								' GROUP BY days');
	$rowcount = $xoopsDB->getAffectedRows($confHdl);
	$total = 0;

	echo "<table>";
	echo "<tr><th>Days</th><th>Reg Count</th></tr>";

	for ($i=1;$i<=$rowcount;$i++) {
		$confData = $xoopsDB->fetchArray($confHdl);
		echo '<tr><td>' . $confData['days'] . ':&nbsp;</td>';
		echo '<td>' . $confData['reg_count'] . '</td></tr>';
		$total += $confData['reg_count'];
	}
//	$total += $confData['reg_count'];

	echo '<tr><td>&nbsp;</td><td>===========</td></tr>';
	echo '<tr><td>Total:</td><td>'.$total.'</td></tr>';

	echo '</table>';

	echo '<h3>Baseball Game Attendence</h3>';

	// temp
	$confid = 1;

	$bHdl =& $xoopsDB->query("SELECT COUNT(*), SUM(guests) FROM " . $xoopsDB->prefix("confreg_baseball") .
							 " WHERE (confid=" . $confid . ")");
	$result = $xoopsDB->fetchRow($bHdl);

	$tHdl =& $xoopsDB->query("SELECT COUNT(*), SUM(guests) FROM " . $xoopsDB->prefix("confreg_baseball") .
							 " WHERE ((confid=" . $confid . ") AND (transport = 1))");
	$transport = $xoopsDB->fetchRow($tHdl);
	$transtotal = $transport[0] + $transport[1];

	echo "<table>";
	echo '<tr><td>Conference Attendees:</td><td>' . $result[0] . '</td></tr>';
	echo '<tr><td>Guests:</td><td>' . $result[1] . '</td></tr>';
	echo '<tr><td>Total Attendees:</td><td>' . ($result[0] + $result[1]) . '</td></tr>';
	echo '<tr><td>Total needing transport:</td><td>' . $transtotal . '</td></tr>';
	echo '</table>';
	
// 	$workHdl = $xoopsDB->query(	'SELECT w.title AS title, count(*) AS how_many' .
// 								' FROM ' . $xoopsDB->prefix('confreg_workshop_res') . ' r' .
// 								' JOIN ' . $xoopsDB->prefix('confreg_workshops') . ' w' .
// 								' ON r.workshopid = w.workshopid' .
// 								' WHERE r.confid = 1' .
// 								' GROUP BY r.workshopid');
// 	$rowcount = $xoopsDB->getAffectedRows($workHdl);
// 
// 	echo '<br /><br /><table>';
// 
// 	echo '<h3>Workshop Attendence</h3>';
// 	echo '<tr><th>Workshop Title</th><th>Reg Count</th></tr>';
// 	for ($i=1;$i<=$rowcount;$i++) {
// 		$workData = $xoopsDB->fetchArray($workHdl);
// 		echo '<tr><td>' . $workData['title'] . '</td><td>' . $workData['how_many'] . '</td></tr>';
// 	}
// 	echo '</table>';

	// for each workshop, list who is attending
	$workHdl = $xoopsDB->query(	'SELECT title, workshopid' .
								' FROM ' . $xoopsDB->prefix('confreg_workshops') .
								' WHERE confid = 1');
	
	echo '<h3>People registered for each workshop</h3>';
	while ($workData = $xoopsDB->fetchArray($workHdl)){
		echo '<p><table>';
		$aHdl = $xoopsDB->query(	'SELECT p.first_name AS fname, p.last_name as lname' .
								' FROM ' . $xoopsDB->prefix('confreg_people') . ' p' .
								' JOIN ' . $xoopsDB->prefix('confreg_workshop_res') . ' r' .
								' ON r.userid = p.userid' .
								' WHERE ((p.confid = 1) AND (r.workshopid = ' . $workData['workshopid'] . '))');
		$rcount = $xoopsDB->getAffectedRows($aHdl);
		echo '<tr><th>' . $workData['title'] . ' ('.$rcount. ')</th></tr>';
		while ($attendee = $xoopsDB->fetchArray($aHdl)){
			echo '<tr><td>' . $attendee['fname'] . ' ' . $attendee['lname'] . '</td></tr>';
		}
		echo '</table></p>';

	}


/**
* and here.
*/
//And put footer in
xoops_cp_footer();

/*
 * This file was generated by XBS ModGen, (c) 2006 A Kitson, UK. See http://xoobs.net
 * ModGen is a Module Code Generator for the Xoops CMS.  See http://xoops.org
 */
?>